package test;
 import GameLogic.*;
import Input.*;
import OGLRenderer.*;
 import org.lwjgl.opengl.Display;
 import utilities.*;
import java.util.ArrayList;


public class OGL_anim {
    public static void main(String[] aa){
        EntityModel model = new EntityModel();

        model.frames=6;
        model.texture_path="src/test/Toki2";
        model.texture_coordinates=  new float[] {0.0f, 0.0f,
                                                0.0f, 1.0f,
                                                1.0f, 1.0f,
                                                1.0f, 0.0f};
        model.vertex_colour =      new float[] {0.0f, 0.0f, 0.0f, 1.0f,
                                        0.0f, 0.0f, 0.0f, 1.0f,
                                        0.0f, 0.0f, 0.0f, 1.0f,
                                        0.0f, 0.0f, 0.0f, 1.0f};

        model.vertices =  new float[] {-0.5f, -0.5f,
                                     0.5f, -0.5f,
                                     0.5f, 0.5f,
                                     -0.5f, 0.5f};

        GL_Renderer ekran = new GL_Renderer("Toki", 1000, 600, false);
        EntityCoordinate coord = new EntityCoordinate(0.0, 0.0,0.2, -90.0f, 1.0f, 1.0f, ekran.LoadObject(model));
        ArrayList<EntityCoordinate> aaa = new ArrayList<EntityCoordinate>();
        aaa.add(coord);
        aaa.add(new EntityCoordinate(-1.0, -1.0,1.0, 0.0f, 1.0f, 1.0f, aaa.get(0).modelID));
        aaa.add(new EntityCoordinate(-1.0, 0.0,0.2, -90.0f, 1.0f, 1.0f, aaa.get(0).modelID));
         aaa.add(new EntityCoordinate(-1.0, 1.0,-1.0, -90.0f, 1.0f, 1.0f, aaa.get(0).modelID));
        BasicInput bi = new BasicInput(); //init input
        int a = bi.update();
        double tmp = 0;
        double tmp2 = 0;
        float tmp3 =0;
        boolean bbb = false;
        int xx = 1;
        ekran.ChangeProjection();
        long st = System.currentTimeMillis();
        while (!Display.isCloseRequested()) {
            ekran.DrawFrame(aaa, 0.0, 0.0);
            a = bi.update();
            switch (a){
                case 1 : tmp = -0.01 ; break;

                case 2 : tmp = 0.01; break;

                case 3 : tmp2 = -0.01; break;
                case 4 : tmp2 = 0.01; break;

                case 5 : bbb = !bbb; ekran.ChangeProjection(); break;

                case 11 : tmp = 0; break;
                case 12 : tmp = 0; break;

                case 13 : tmp2 = 0; break;
                case 14 : tmp2 = 0; break;

                //case 15 : tmp3 = 0;




            }
            if((tmp>0 && aaa.get(0).posY+tmp<0.6) || (tmp<0 && aaa.get(0).posY+tmp>-1))
            	aaa.get(0).posY+= tmp;  //values are passed as references, so we can apply changes directly
            if((tmp2>0 && aaa.get(0).posX+tmp2<1.8) || (tmp2<0 && aaa.get(0).posX+tmp2>-1.7))
            	aaa.get(0).posX+= tmp2;
            //System.out.println(aaa.get(0).posX+":"+aaa.get(0).posY);

            if((System.currentTimeMillis() - st > 40) && bbb){
                aaa.get(0).animFrame++;
                if(model.frames <= aaa.get(0).animFrame)
                   // xx = -xx;
                	aaa.get(0).animFrame = 0;


                st =  System.currentTimeMillis();
            }
        }



    }
}
